import show_modal from './show_modal.js'
function show_modal_fun(op = {}) {
	//#ifdef APP-PLUS
	return new Promise((resolve, reject) => {
		let ssm = new show_modal({
			...op,
			$event: function(e) {
				if (e.res) {
					resolve(e);
				} else {
					reject(e);
				}
			}
		});
		ssm.show();
	})
	//#endif
	// 适应H5
	//#ifdef H5 || MP-WEIXIN
	return new Promise((resolve, reject) => {
		uni.showModal({
			title: op.title || '提示',
			content: op.content || '',
			showCancel: op.showCancel === undefined ? true : op.showCancel,
			cancelText: op.cancelVal || '取消',
			confirmText: op.confirmVal || '确定',
			confirmColor: op.confirmColor || uni.$xl.global.themeColor || '#333',
			cancelColor: op.cancelColor || '#666',
			success(res) {
				if (res.confirm) {
					resolve()
				} else if (res.cancel){
					reject()
				}
			}
		});
	})
	//#endif
}
export default show_modal_fun